import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';

import { Meteor } from 'meteor/meteor';

class LockFingerprintsCollection extends Mongo.Collection {
    update(selector, modifier) {
        const result = super.update(selector, modifier);
        return result;
    }
    insert(family, callback) {
        const ourLockFingerprints = family;
        const result = super.insert(ourLockFingerprints, callback);
        return result;
    }
    remove(selector, callback) {
        const result = super.remove(selector, callback);
        return result;
    }
}

export const LockFingerprints = new LockFingerprintsCollection('lock_fingerprints');

LockFingerprints.deny({
    insert() { return true; },
    update() { return true; },
    remove() { return true; },
});

LockFingerprints.schema = new SimpleSchema({
    row: {
        label: '行数',
        type: Number,
    },
    finger: {
        label: '指纹ID',
        type: String,
        optional: true
    },
    finger_valid_period: {
        label: '指纹有效期',
        type: Date,
        optional: true
    },
    finger_remain_times: {
        label: '指纹剩余次数',
        type: Number,
        optional: true
    },
    deviceId: {
        label: '锁ＩＤ',
        type: String,
        optional: true
    },
    user_phone: {
        label: '使用者手机号',
        type: String,
        optional: true
    },
    user_id: {
        label: '使用者ID',
        type: String,
        optional: true
    },
    create_uid: {
        label: '用户ＩＤ',
        type: String,
    },
    create_uname: {
        label: '用户名',
        type: String,
    },
    c_date: {
        label: '创建时间',
        type: Date
    }
});
LockFingerprints.attachSchema(LockFingerprints.schema);
